package com.zzc.election_server.controller;

import com.alibaba.fastjson.JSONObject;
import com.zzc.election_server.common.Result;
import com.zzc.election_server.modelExtend.ExtGrade;
import com.zzc.election_server.modelExtend.ExtStudent;
import com.zzc.election_server.service.GradeService;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author caopengflying
 * @time 2019/1/30 13:38
 */
@RestController
@RequestMapping(value = "grade", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class GradeController {
    public static void main(String[] args) {
        String companyKey = "00057100";
        String pwd = "e10adc3949ba59abbe56e057f20f883e";
        String user = "lq_test";
        String loginKey = "88aa969a72f9ikqwmnl5w6wbb+7qngejxa==c3ac016feed0346789c4";
        String url = "http://api.jqzjip.com:8083/jip-web/api/v1/getUserToken";
        Long timestamp = System.currentTimeMillis() / 1000;
        String a = "companyKey" + companyKey + "pwd" + pwd + "timestamp" + timestamp + "user" + user;
        String upperCase = StringUtils.upperCase(loginKey + a);
        String sign = DigestUtils.md5Hex(upperCase);
        System.out.println(timestamp);
        System.out.println(sign);

    }
    @Resource
    private GradeService gradeService;

    @RequestMapping(value = "create")
    public Result create(String jsonObject){
        ExtGrade extGrade = JSONObject.parseObject(jsonObject, ExtGrade.class);
        return gradeService.create(extGrade);
    }
    @RequestMapping("delete")
    public Result delete(String jsonObject){
        ExtGrade extGrade = JSONObject.parseObject(jsonObject, ExtGrade.class);
        return gradeService.delete(extGrade);
    }
    @RequestMapping("update")
    public Result update(String jsonObject){
        ExtGrade extGrade = JSONObject.parseObject(jsonObject, ExtGrade.class);
        return gradeService.update(extGrade);
    }
    @RequestMapping("list")
    public Result list(String jsonObject){
        ExtGrade extGrade = JSONObject.parseObject(jsonObject, ExtGrade.class);
        return gradeService.list(extGrade);
    }
}
